#!/usr/bin/python
# coding=UTF-8
#import RPi.GPIO as GPIO
import serial
import time
from threading import Timer
import datetime
#change you port
serport = serial.Serial("/dev/ttyUSB0",460800)
serport.flushInput()
time.sleep(0.5)#单位是s
while True:
    rxData =str(str(serport.readline())) #读取里面的内容
    #print(rxData)
    if rxData.find(str('$GNGGA'))!=-1:#
      #print(rxData)
      line = str(rxData).split(',')  # 将line以“，”为分隔符
      if line[3]=='N':#dingwei is ok
          weidu = float(line[2][:2]) + float(line[2][2:])/60
            # 读取第5个字符串信息，从0-3为经度，即经度为117，再加上后面的一串除60将分转化为度
          jingdu = float(line[4][:3]) + float(line[4][3:])/60
            # 纬度同理
          print("longitude:",'{:.6f}'.format(jingdu))
          print("latitude:",'{:.6f}'.format(weidu))
          current_time = datetime.datetime.now()
          #print("当前时间：", current_time)
      if line[6]=='1':
          print ('GPS DATA VAULE')
      elif line[6]=='2':
          print('DIFF MODE')
      elif line[6]=='4':
          print('RTK FIXD')
      elif line[6]=='5':
          print('RTK FLOAT')
          
   # time.sleep(0.1)#单位是s

         
         
